import request from '@/utils/request'

// api地址
const api = {
  list: '/app/car/list',
  total: '/app/car/total',
  add: '/app/car/add',
  update: '/app/car/update',
  clear: '/app/car/clear',
}


// 购物车列表
export const list = () => {
  return request.get(api.list, {}, { load: false })
}

// 购物车商品总数量
export const total = () => {
  return request.get(api.total, {}, { load: false })
}

// 加入购物车
export const add = (goodsId, skuId, quantity) => {
  return request.get(api.add, { goodsId, skuId, quantity })
}

// 更新购物车商品数量
export const update = (goodsId, skuId, quantity) => {
  return request.get(api.update, { goodsId,  skuId, quantity }, { isPrompt: false })
}

// 删除购物车中指定记录
export const clear = (cartIds = []) => {
  return request.get(api.clear + "?ids=" + cartIds.join(','))
}
